package com.zzyl.nursing.task;

import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.service.member.MemberReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * 定时任务
 * @author yhy
 */

@Slf4j
@Configuration
public class MemberStatusTack {

    @Autowired
    private MemberReservationService memberReservationService;

    public void updateMemberReservationStatus() {
        log.info("开始预约状态");

        List<Reservation> reservations = memberReservationService.selectReservationStatus();

        reservations.forEach(reservation -> {
            reservation.setStatus(3);
        });

        memberReservationService.updateBatchById(reservations);
        log.info("更新预约状态结束");
    }
}
